package pattern.proxy;

import pattern.proxy.interceptor.Interceptor;

public class ProxyFactory{

	public static <T> Proxy createProxy(Class<T> clazz, Interceptor interceptor) throws Exception {
		
		 Class c = Class.forName(clazz.getCanonicalName());
		 
		 T instance = (T)c.newInstance();
		 Proxy proxy = new ProxyTemplate(instance, interceptor);

		 
		 return proxy;
		
	}
	
	public static <T> Proxy createProxy(Class<T> clazz) throws Exception {
		
		 Class c = Class.forName(clazz.getCanonicalName());
		 
		 T instance = (T)c.newInstance();
		 Proxy proxy = new ProxyTemplate(instance);

		 
		 return proxy;
		
	}
	
	
}
